﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;//Please add references
namespace TierApplication
{
	/// <summary>
	/// 类T_ACCOUNT。
	/// </summary>
	[Serializable]
	public partial class T_ACCOUNT
	{
		public T_ACCOUNT()
		{}
		#region Model
		private string _accountid;
		private string _accountname;
		private string _accountpwd;
		private string _schoolid;
		private string _sno;
		private string _idcard;
		private string _email;
		private string _mobile;
		private string _roleid;
		private string _gender;
		private DateTime? _birthday;
		private string _contac_addr;
		private string _postcode;
		private decimal? _currentpoint;
		private string _isemailconfirm;
		private string _grade;
		/// <summary>
		/// 账号名
		/// </summary>
		public string ACCOUNTID
		{
			set{ _accountid=value;}
			get{return _accountid;}
		}
		/// <summary>
		/// 姓名
		/// </summary>
		public string ACCOUNTNAME
		{
			set{ _accountname=value;}
			get{return _accountname;}
		}
		/// <summary>
		/// 账号密码
		/// </summary>
		public string ACCOUNTPWD
		{
			set{ _accountpwd=value;}
			get{return _accountpwd;}
		}
		/// <summary>
		/// 学校
		/// </summary>
		public string SCHOOLID
		{
			set{ _schoolid=value;}
			get{return _schoolid;}
		}
		/// <summary>
		/// 学号
		/// </summary>
		public string SNO
		{
			set{ _sno=value;}
			get{return _sno;}
		}
		/// <summary>
		/// 身份证号
		/// </summary>
		public string IDCARD
		{
			set{ _idcard=value;}
			get{return _idcard;}
		}
		/// <summary>
		/// 电子邮件
		/// </summary>
		public string EMAIL
		{
			set{ _email=value;}
			get{return _email;}
		}
		/// <summary>
		/// 手机号码
		/// </summary>
		public string MOBILE
		{
			set{ _mobile=value;}
			get{return _mobile;}
		}
		/// <summary>
		/// 角色
		/// </summary>
		public string ROLEID
		{
			set{ _roleid=value;}
			get{return _roleid;}
		}
		/// <summary>
		/// 性别C_Gender
		/// </summary>
		public string GENDER
		{
			set{ _gender=value;}
			get{return _gender;}
		}
		/// <summary>
		/// 出生日期
		/// </summary>
		public DateTime? BIRTHDAY
		{
			set{ _birthday=value;}
			get{return _birthday;}
		}
		/// <summary>
		/// 联系地址
		/// </summary>
		public string CONTAC_ADDR
		{
			set{ _contac_addr=value;}
			get{return _contac_addr;}
		}
		/// <summary>
		/// 邮编
		/// </summary>
		public string POSTCODE
		{
			set{ _postcode=value;}
			get{return _postcode;}
		}
		/// <summary>
		/// 当前积分
		/// </summary>
		public decimal? CURRENTPOINT
		{
			set{ _currentpoint=value;}
			get{return _currentpoint;}
		}
		/// <summary>
		/// 电子邮件是否已验证
		/// </summary>
		public string ISEMAILCONFIRM
		{
			set{ _isemailconfirm=value;}
			get{return _isemailconfirm;}
		}
		/// <summary>
		/// 用户级别
		/// </summary>
		public string GRADE
		{
			set{ _grade=value;}
			get{return _grade;}
		}
		#endregion Model


		#region  Method

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public T_ACCOUNT(string ACCOUNTID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ACCOUNTID,ACCOUNTNAME,ACCOUNTPWD,SCHOOLID,SNO,IDCARD,EMAIL,MOBILE,ROLEID,GENDER,BIRTHDAY,CONTAC_ADDR,POSTCODE,CURRENTPOINT,ISEMAILCONFIRM,GRADE ");
			strSql.Append(" FROM T_ACCOUNT ");
			strSql.Append(" where ACCOUNTID=:ACCOUNTID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,50)};
			parameters[0].Value = ACCOUNTID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["ACCOUNTID"]!=null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString()!="")
				{
					this.ACCOUNTID=ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTNAME"]!=null && ds.Tables[0].Rows[0]["ACCOUNTNAME"].ToString()!="")
				{
					this.ACCOUNTNAME=ds.Tables[0].Rows[0]["ACCOUNTNAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTPWD"]!=null && ds.Tables[0].Rows[0]["ACCOUNTPWD"].ToString()!="")
				{
					this.ACCOUNTPWD=ds.Tables[0].Rows[0]["ACCOUNTPWD"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLID"]!=null && ds.Tables[0].Rows[0]["SCHOOLID"].ToString()!="")
				{
					this.SCHOOLID=ds.Tables[0].Rows[0]["SCHOOLID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SNO"]!=null && ds.Tables[0].Rows[0]["SNO"].ToString()!="")
				{
					this.SNO=ds.Tables[0].Rows[0]["SNO"].ToString();
				}
				if(ds.Tables[0].Rows[0]["IDCARD"]!=null && ds.Tables[0].Rows[0]["IDCARD"].ToString()!="")
				{
					this.IDCARD=ds.Tables[0].Rows[0]["IDCARD"].ToString();
				}
				if(ds.Tables[0].Rows[0]["EMAIL"]!=null && ds.Tables[0].Rows[0]["EMAIL"].ToString()!="")
				{
					this.EMAIL=ds.Tables[0].Rows[0]["EMAIL"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MOBILE"]!=null && ds.Tables[0].Rows[0]["MOBILE"].ToString()!="")
				{
					this.MOBILE=ds.Tables[0].Rows[0]["MOBILE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ROLEID"]!=null && ds.Tables[0].Rows[0]["ROLEID"].ToString()!="")
				{
					this.ROLEID=ds.Tables[0].Rows[0]["ROLEID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GENDER"]!=null && ds.Tables[0].Rows[0]["GENDER"].ToString()!="")
				{
					this.GENDER=ds.Tables[0].Rows[0]["GENDER"].ToString();
				}
				if(ds.Tables[0].Rows[0]["BIRTHDAY"]!=null && ds.Tables[0].Rows[0]["BIRTHDAY"].ToString()!="")
				{
					this.BIRTHDAY=DateTime.Parse(ds.Tables[0].Rows[0]["BIRTHDAY"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CONTAC_ADDR"]!=null && ds.Tables[0].Rows[0]["CONTAC_ADDR"].ToString()!="")
				{
					this.CONTAC_ADDR=ds.Tables[0].Rows[0]["CONTAC_ADDR"].ToString();
				}
				if(ds.Tables[0].Rows[0]["POSTCODE"]!=null && ds.Tables[0].Rows[0]["POSTCODE"].ToString()!="")
				{
					this.POSTCODE=ds.Tables[0].Rows[0]["POSTCODE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CURRENTPOINT"]!=null && ds.Tables[0].Rows[0]["CURRENTPOINT"].ToString()!="")
				{
					this.CURRENTPOINT=decimal.Parse(ds.Tables[0].Rows[0]["CURRENTPOINT"].ToString());
				}
				if(ds.Tables[0].Rows[0]["ISEMAILCONFIRM"]!=null && ds.Tables[0].Rows[0]["ISEMAILCONFIRM"].ToString()!="")
				{
					this.ISEMAILCONFIRM=ds.Tables[0].Rows[0]["ISEMAILCONFIRM"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GRADE"]!=null && ds.Tables[0].Rows[0]["GRADE"].ToString()!="")
				{
					this.GRADE=ds.Tables[0].Rows[0]["GRADE"].ToString();
				}
			}
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string ACCOUNTID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from T_ACCOUNT");
			strSql.Append(" where ACCOUNTID=:ACCOUNTID ");

			OracleParameter[] parameters = {
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,50)};
			parameters[0].Value = ACCOUNTID;

			return DbHelperOra.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_ACCOUNT (");
			strSql.Append("ACCOUNTID,ACCOUNTNAME,ACCOUNTPWD,SCHOOLID,SNO,IDCARD,EMAIL,MOBILE,ROLEID,GENDER,BIRTHDAY,CONTAC_ADDR,POSTCODE,CURRENTPOINT,ISEMAILCONFIRM,GRADE)");
			strSql.Append(" values (");
			strSql.Append(":ACCOUNTID,:ACCOUNTNAME,:ACCOUNTPWD,:SCHOOLID,:SNO,:IDCARD,:EMAIL,:MOBILE,:ROLEID,:GENDER,:BIRTHDAY,:CONTAC_ADDR,:POSTCODE,:CURRENTPOINT,:ISEMAILCONFIRM,:GRADE)");
			OracleParameter[] parameters = {
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20),
					new OracleParameter(":ACCOUNTNAME", OracleType.VarChar,60),
					new OracleParameter(":ACCOUNTPWD", OracleType.VarChar,90),
					new OracleParameter(":SCHOOLID", OracleType.VarChar,10),
					new OracleParameter(":SNO", OracleType.VarChar,20),
					new OracleParameter(":IDCARD", OracleType.VarChar,18),
					new OracleParameter(":EMAIL", OracleType.VarChar,60),
					new OracleParameter(":MOBILE", OracleType.VarChar,11),
					new OracleParameter(":ROLEID", OracleType.VarChar,10),
					new OracleParameter(":GENDER", OracleType.VarChar,1),
					new OracleParameter(":BIRTHDAY", OracleType.DateTime),
					new OracleParameter(":CONTAC_ADDR", OracleType.VarChar,200),
					new OracleParameter(":POSTCODE", OracleType.VarChar,6),
					new OracleParameter(":CURRENTPOINT", OracleType.Number,12),
					new OracleParameter(":ISEMAILCONFIRM", OracleType.VarChar,1),
					new OracleParameter(":GRADE", OracleType.VarChar,1)};
			parameters[0].Value = ACCOUNTID;
			parameters[1].Value = ACCOUNTNAME;
			parameters[2].Value = ACCOUNTPWD;
			parameters[3].Value = SCHOOLID;
			parameters[4].Value = SNO;
			parameters[5].Value = IDCARD;
			parameters[6].Value = EMAIL;
			parameters[7].Value = MOBILE;
			parameters[8].Value = ROLEID;
			parameters[9].Value = GENDER;
			parameters[10].Value = BIRTHDAY;
			parameters[11].Value = CONTAC_ADDR;
			parameters[12].Value = POSTCODE;
			parameters[13].Value = CURRENTPOINT;
			parameters[14].Value = ISEMAILCONFIRM;
			parameters[15].Value = GRADE;

			DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_ACCOUNT set ");
			strSql.Append("ACCOUNTNAME=:ACCOUNTNAME,");
			strSql.Append("ACCOUNTPWD=:ACCOUNTPWD,");
			strSql.Append("SCHOOLID=:SCHOOLID,");
			strSql.Append("SNO=:SNO,");
			strSql.Append("IDCARD=:IDCARD,");
			strSql.Append("EMAIL=:EMAIL,");
			strSql.Append("MOBILE=:MOBILE,");
			strSql.Append("ROLEID=:ROLEID,");
			strSql.Append("GENDER=:GENDER,");
			strSql.Append("BIRTHDAY=:BIRTHDAY,");
			strSql.Append("CONTAC_ADDR=:CONTAC_ADDR,");
			strSql.Append("POSTCODE=:POSTCODE,");
			strSql.Append("CURRENTPOINT=:CURRENTPOINT,");
			strSql.Append("ISEMAILCONFIRM=:ISEMAILCONFIRM,");
			strSql.Append("GRADE=:GRADE");
			strSql.Append(" where ACCOUNTID=:ACCOUNTID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ACCOUNTNAME", OracleType.VarChar,60),
					new OracleParameter(":ACCOUNTPWD", OracleType.VarChar,90),
					new OracleParameter(":SCHOOLID", OracleType.VarChar,10),
					new OracleParameter(":SNO", OracleType.VarChar,20),
					new OracleParameter(":IDCARD", OracleType.VarChar,18),
					new OracleParameter(":EMAIL", OracleType.VarChar,60),
					new OracleParameter(":MOBILE", OracleType.VarChar,11),
					new OracleParameter(":ROLEID", OracleType.VarChar,10),
					new OracleParameter(":GENDER", OracleType.VarChar,1),
					new OracleParameter(":BIRTHDAY", OracleType.DateTime),
					new OracleParameter(":CONTAC_ADDR", OracleType.VarChar,200),
					new OracleParameter(":POSTCODE", OracleType.VarChar,6),
					new OracleParameter(":CURRENTPOINT", OracleType.Number,12),
					new OracleParameter(":ISEMAILCONFIRM", OracleType.VarChar,1),
					new OracleParameter(":GRADE", OracleType.VarChar,1),
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,20)};
			parameters[0].Value = ACCOUNTNAME;
			parameters[1].Value = ACCOUNTPWD;
			parameters[2].Value = SCHOOLID;
			parameters[3].Value = SNO;
			parameters[4].Value = IDCARD;
			parameters[5].Value = EMAIL;
			parameters[6].Value = MOBILE;
			parameters[7].Value = ROLEID;
			parameters[8].Value = GENDER;
			parameters[9].Value = BIRTHDAY;
			parameters[10].Value = CONTAC_ADDR;
			parameters[11].Value = POSTCODE;
			parameters[12].Value = CURRENTPOINT;
			parameters[13].Value = ISEMAILCONFIRM;
			parameters[14].Value = GRADE;
			parameters[15].Value = ACCOUNTID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string ACCOUNTID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_ACCOUNT ");
			strSql.Append(" where ACCOUNTID=:ACCOUNTID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,50)};
			parameters[0].Value = ACCOUNTID;

			int rows=DbHelperOra.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public void GetModel(string ACCOUNTID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ACCOUNTID,ACCOUNTNAME,ACCOUNTPWD,SCHOOLID,SNO,IDCARD,EMAIL,MOBILE,ROLEID,GENDER,BIRTHDAY,CONTAC_ADDR,POSTCODE,CURRENTPOINT,ISEMAILCONFIRM,GRADE ");
			strSql.Append(" FROM T_ACCOUNT ");
			strSql.Append(" where ACCOUNTID=:ACCOUNTID ");
			OracleParameter[] parameters = {
					new OracleParameter(":ACCOUNTID", OracleType.VarChar,50)};
			parameters[0].Value = ACCOUNTID;

			DataSet ds=DbHelperOra.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["ACCOUNTID"]!=null && ds.Tables[0].Rows[0]["ACCOUNTID"].ToString()!="")
				{
					this.ACCOUNTID=ds.Tables[0].Rows[0]["ACCOUNTID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTNAME"]!=null && ds.Tables[0].Rows[0]["ACCOUNTNAME"].ToString()!="")
				{
					this.ACCOUNTNAME=ds.Tables[0].Rows[0]["ACCOUNTNAME"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ACCOUNTPWD"]!=null && ds.Tables[0].Rows[0]["ACCOUNTPWD"].ToString()!="")
				{
					this.ACCOUNTPWD=ds.Tables[0].Rows[0]["ACCOUNTPWD"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SCHOOLID"]!=null && ds.Tables[0].Rows[0]["SCHOOLID"].ToString()!="")
				{
					this.SCHOOLID=ds.Tables[0].Rows[0]["SCHOOLID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SNO"]!=null && ds.Tables[0].Rows[0]["SNO"].ToString()!="")
				{
					this.SNO=ds.Tables[0].Rows[0]["SNO"].ToString();
				}
				if(ds.Tables[0].Rows[0]["IDCARD"]!=null && ds.Tables[0].Rows[0]["IDCARD"].ToString()!="")
				{
					this.IDCARD=ds.Tables[0].Rows[0]["IDCARD"].ToString();
				}
				if(ds.Tables[0].Rows[0]["EMAIL"]!=null && ds.Tables[0].Rows[0]["EMAIL"].ToString()!="")
				{
					this.EMAIL=ds.Tables[0].Rows[0]["EMAIL"].ToString();
				}
				if(ds.Tables[0].Rows[0]["MOBILE"]!=null && ds.Tables[0].Rows[0]["MOBILE"].ToString()!="")
				{
					this.MOBILE=ds.Tables[0].Rows[0]["MOBILE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ROLEID"]!=null && ds.Tables[0].Rows[0]["ROLEID"].ToString()!="")
				{
					this.ROLEID=ds.Tables[0].Rows[0]["ROLEID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GENDER"]!=null && ds.Tables[0].Rows[0]["GENDER"].ToString()!="")
				{
					this.GENDER=ds.Tables[0].Rows[0]["GENDER"].ToString();
				}
				if(ds.Tables[0].Rows[0]["BIRTHDAY"]!=null && ds.Tables[0].Rows[0]["BIRTHDAY"].ToString()!="")
				{
					this.BIRTHDAY=DateTime.Parse(ds.Tables[0].Rows[0]["BIRTHDAY"].ToString());
				}
				if(ds.Tables[0].Rows[0]["CONTAC_ADDR"]!=null && ds.Tables[0].Rows[0]["CONTAC_ADDR"].ToString()!="")
				{
					this.CONTAC_ADDR=ds.Tables[0].Rows[0]["CONTAC_ADDR"].ToString();
				}
				if(ds.Tables[0].Rows[0]["POSTCODE"]!=null && ds.Tables[0].Rows[0]["POSTCODE"].ToString()!="")
				{
					this.POSTCODE=ds.Tables[0].Rows[0]["POSTCODE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CURRENTPOINT"]!=null && ds.Tables[0].Rows[0]["CURRENTPOINT"].ToString()!="")
				{
					this.CURRENTPOINT=decimal.Parse(ds.Tables[0].Rows[0]["CURRENTPOINT"].ToString());
				}
				if(ds.Tables[0].Rows[0]["ISEMAILCONFIRM"]!=null && ds.Tables[0].Rows[0]["ISEMAILCONFIRM"].ToString()!="")
				{
					this.ISEMAILCONFIRM=ds.Tables[0].Rows[0]["ISEMAILCONFIRM"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GRADE"]!=null && ds.Tables[0].Rows[0]["GRADE"].ToString()!="")
				{
					this.GRADE=ds.Tables[0].Rows[0]["GRADE"].ToString();
				}
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select * ");
			strSql.Append(" FROM T_ACCOUNT ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperOra.Query(strSql.ToString());
		}

		#endregion  Method
	}
}

